package com.jk.controller;


import cn.hutool.core.util.URLUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("http")
@CrossOrigin(origins = "*")
public class JiController {
    @RequestMapping("aiReply")
    public  String aiReply(String content){
        String body = HttpRequest.get("https://api.qingyunke.com/api.php?key=free&appid=0&msg="+content)
                .execute().charset("utf-8").body();
        JSONObject jsonObject = JSONUtil.parseObj(body);
        if (jsonObject.getStr("result").equals("0")) {
            return jsonObject.getStr("content");
        }else {
            return "操作频繁！！！";
        }
    }
}
